package com.zengqingfa.examples.mybatisplus.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;

/**
 * @Description: 动态列表更新请求参数
 * @Date: 2022/10/9
 */
@Data
@ApiModel(value = "动态列表更新请求参数")
public class DynamicColumnUpdateDTO {
    @ApiModelProperty(value = "模块：1:供应商", required = true)
    @NotNull(message = "模块不能为空")
    @Range(min = 1, max = 1, message = "模块：1:供应商")
    private Integer module;

    @ApiModelProperty(value = "列表信息")
    @NotEmpty(message = "列表信息不能为空")
    @Valid
    private List<ColumnInfoRequest> columnInfo;

    @Data
    public static class ColumnInfoRequest {
        @ApiModelProperty(value = "字段名称")
        @NotBlank(message = "字段名称不能为空")
        private String field;

        @ApiModelProperty(value = "数据库字段名称")
        @NotBlank(message = "数据库字段名称不能为空")
        private String databaseField;

        @ApiModelProperty(value = "是否显示")
        @NotNull(message = "是否显示字段不能为空")
        private Boolean show;

        @ApiModelProperty(value = "排序")
        @NotNull(message = "排序字段不能为空")
        private Integer order;

        @ApiModelProperty(value = "是否固定在左右侧：l 固定在左侧，r 固定在右侧")
        @Pattern(regexp = "[lr]?", message = "是否固定在左右侧：l 固定在左侧，r 固定在右侧")
        private String fixed;
    }
}
